package com.base.interceptor;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;
import com.system.struts2.util.PersonUtil;



public class LoginInterceptor extends MethodFilterInterceptor {



	protected String doIntercept(ActionInvocation invocation) throws Exception {
		// TODO Auto-generated method stub
		HttpServletRequest request = ServletActionContext.getRequest();
		HttpServletResponse response  =ServletActionContext.getResponse();

		if (PersonUtil.getPersonInfo(request, response) == null)
		{
			String action = invocation.getAction().toString();
			String actionpg[] = action.split("\\.");
			request.setAttribute("logout", "您还没有登录，请登陆系统");
			if(actionpg[1].equals("jingyanku"))
			{
			  return "jingyanku_lg";
			}else if(actionpg[1].equals("worklog")){
				return "worklog_lg";
			}else if(actionpg[1].equals("fieldIndustry")){
				return "industry_lg";
			}else if(actionpg[1].equals("system")){
				return "system_lg";
			}
			}
		
		
		return invocation.invoke();   
	}
}
